package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.Employee;
import cn.wolfcode.crm.mapper.EmployeeMapper;
import cn.wolfcode.crm.service.IEmployeeService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;


    public void save(Employee employee) {
        employeeMapper.insert(employee);
    }

    public void update(Employee employee) {
        employeeMapper.updateByPrimaryKey(employee);
    }

    public void delete(Long id) {
        employeeMapper.deleteByPrimaryKey(id);
    }

    public Employee get(Long id) {

        return employeeMapper.selectByPrimaryKey(id);
    }

    public PageResult list() {
        List<Employee> rows = employeeMapper.selectAll();
        return new PageResult(rows.size(), rows);
    }


    @Override
    public List<Employee> listAll() {
        return employeeMapper.selectAll();
    }




}
